/*--------------------------------------------------------------
 * File: debug.h 编码类型：C语言  UTF-8
 * Author WRS (1352509846@qq.com)
 * 功能: 重定向printf函数，通过串口打印调试信息
 * Version 0.1
 * Date 2024-03-27 
 * 
 * @copyright Copyright (c) 2024
 * 
----------------------------------------------------------------*/
#ifndef __DEBUG_H__
#define __DEBUG_H__

#include <stdio.h>
#include <errno.h>

//定义下面这些宏--打开调试模式
#define _MY_INFO_
#define _MY_DEBUG_
#define _MY_ERROR_
#define _MY_NOTICE_
#define _MY_JSON_

#ifdef _MY_INFO_
#define TAG0  "[ INFO ] "  //打印普通信息
#define MY_INFO(format,...) printf(TAG0  format "\n", ##__VA_ARGS__)
#else
#define MY_INFO(format,...)
#endif

#ifdef _MY_DEBUG_
#define TAG1  "[DEBUG ] "  //调试信息
#define MY_DEBUG(format,...) printf(TAG1  "%s %d " format "\n", __func__, __LINE__, ##__VA_ARGS__)
#else
#define MY_DEBUG(format,...)
#endif

#ifdef _MY_ERROR_
#define TAG2  "[ERROR ] "  //打印错误
#define MY_ERROR(format,...) printf(TAG2  "%s %s %d %s " format "\n", __FILE__, __func__, __LINE__, __TIME__, ##__VA_ARGS__)
#else
#define MY_ERROR(format,...)
#endif

#ifdef _MY_NOTICE_
#define TAG3  "[NOTICE] "       //打印通知
#define MY_NOTICE(format,...)      printf(TAG3  "%s %d " format "\n", __func__, __LINE__, ##__VA_ARGS__)
#else
#define MY_NOTICE(format,...)
#endif

#ifdef _MY_JSON_
#define TAG4  "[ JSON ] "  //调试信息
#define MY_JSON(format,...) printf(TAG1  "%s %d " format "\n", __func__, __LINE__, ##__VA_ARGS__)
#else
#define MY_JSON(format,...)
#endif

#endif
